package com.ermao.learnWebmagic.config;

import lombok.Getter;

@Getter
public enum BilibiliAPIEnum {

	SEARCH("https://api.bilibili.com/x/web-interface/search/type?__refresh__=true&_extra=&context=&page=1&page_size=50&order=click&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&keyword={$}&category_id=&search_type=video&dynamic_offset=0&preload=true&com2co=true", "https://api.bilibili.com/x/web-interface/search/type"),
	UP_SPACE("https://api.bilibili.com/x/space/arc/search?mid={$}&pn=1&ps=30&index=1&jsonp=jsonp", "https://api.bilibili.com/x/space/arc/search"),
	VIDEO_STAT("http://api.bilibili.com/x/web-interface/view?bvid={$}", "http://api.bilibili.com/x/web-interface/view"),
	VIDEO_TAG("http://api.bilibili.com/x/tag/archive/tags?bvid={$}&jsonp=jsonp", "http://api.bilibili.com/x/tag/archive/tags"),

	UP_STAT("https://api.bilibili.com/x/relation/stat?vmid={$}&jsonp=jsonp", "https://api.bilibili.com/x/relation/stat"),
	UP_INFO("https://api.bilibili.com/x/space/acc/info?mid={$}&jsonp=jsonp", "https://api.bilibili.com/x/space/acc/info");

	private final String url;
	private final String urlPrefix;

	BilibiliAPIEnum(String url, String urlPrefix) {
		this.url = url;
		this.urlPrefix = urlPrefix;
	}

	public static String getAPI(BilibiliAPIEnum apiEnum, String holder) {
		return apiEnum.getUrl().replace("{$}", holder);
	}
}
